import 'dart:convert';

import 'package:flutter/material.dart';
import '../../global/Global.dart';
import '../../global/GlobalUrl.dart';
import '../../services/TLSizeFit.dart';
import '../../util/LogUtil.dart';

import '../../YColors.dart';

//import '../pages/YColors.dart';
//import '../bean/order/MarketBean.dart';

Widget ItemToDoTaskView2(context, bean) {
  // TODO: implement build
  return Container(
    width: double.infinity,
    margin: EdgeInsets.fromLTRB(20, 20, 20, 0),
    padding: EdgeInsets.fromLTRB(20, 0, 10, 20),
    child: Column(
      children: <Widget>[
        SizedBox(
          height: 10,
        ),
        Row(
          children: <Widget>[
            Text(
              "流程名称",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: 30,
            ),
            Text(
              bean["name"] != null ? bean["name"] : "",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: 10,
        ),
        Row(
          children: <Widget>[
            Text(
              "任务名称",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: 30,
            ),
            Text(
//              "流程的卡肯德基",
              bean["processDefinitionName"] != null
                  ? bean["processDefinitionName"]
                  : "",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: 10,
        ),
        Row(
          children: <Widget>[
            Text(
              "业务名称",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: 60,
            ),
            Text(
              bean["ppProjectName"] != null ? bean["ppProjectName"] : "",
//              getDataTitle(bean),
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: 10,
        ),
        Row(
          children: <Widget>[
            Text(
              "状态",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: 60,
            ),
            Text(
//              "状态。。。。。",
//              bean["status"]!=null? bean["status"]:"",
              getDataStatusText(bean),
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: 10,
        ),
        Row(
          children: <Widget>[
            Text(
              "开始时间",
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
            SizedBox(
              width: 30,
            ),
            Text(
              bean["createTime"] != null ? bean["createTime"] : "",
//              getDataStatusText(bean),
              style: TextStyle(
                fontSize: 14.0,
                color: YColors.a,
              ),
            ),
          ],
        ),
        SizedBox(
          height: 10,
        ),
        InkWell(
          child: Row(
            children: <Widget>[
              Text(
                "处理待办任务",
                style: TextStyle(
                  fontSize: 14.0,
                  color: YColors.a,
                ),
              ),
//            SizedBox(
//              width: 60,
//            ),
//            Image.asset(
//              'images/user_home_arrow.png',
//              width: TLSizeFit.setPx(18),
//              height: TLSizeFit.setPx(18),
//            ),
            ],
          ),
          onTap: () {
            print("处理待办任务");
          },
        ),
        InkWell(
          child: Container(
            padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
            width: double.infinity,
//            color: YColors.l,
            child: Row(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.fromLTRB(7, 4, 7, 4),
//                  color: YColors.m,
                  child: Text(
                    "查看流程图",
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.a,
                    ),
                  ),

                  decoration: BoxDecoration(
                    color: YColors.m,
                    borderRadius: BorderRadius.all(new Radius.circular(4)),
                  ),
                ),
              ],
            ),
          ),
          onTap: () {
            print("查看流程图");
            String processInstanceId = bean["processInstanceId"];
            print("查看流程图processInstanceId:$processInstanceId");
            if (processInstanceId == null) {
              processInstanceId = "";
            }
            String url = GlobalUrl.WEB_CHART_URL +
                "?processInstanceId=" +
                processInstanceId +
                "&platform=app";
            Navigator.pushNamed(context, '/webViewUtilPage', //WebViewExample
                arguments: {
                  Global.WEBVIEW_TAG: Global.HIISTORYTASK,
                  Global.WEBVIEW_URL: url,
                }).then((value) {
              print('webview:$value');
            });
          },
        ),
      ],
    ),
    decoration: BoxDecoration(
        // 边框 zj
        color: Colors.white, // 背景色 zj
        border: Border.all(
            // 边框 zj
            color: Colors.black12, // 边框颜色 zj
            width: 1.0 // 边框宽度 zj

            ),
        borderRadius: BorderRadius.all(// 圆角
            //  Radius.circular(150),    //圆形
            Radius.circular(6) // 圆角 zj
            ),
        boxShadow: [
          BoxShadow(
//                            color: Colors.black12,
//              color: Color(0x554CBC5A), // 55  是透明度
              color: Color(0x12000000), // 55  是透明度
              offset: Offset(0.0, 2.0), //阴影xy轴偏移量
              blurRadius: 4.0, //阴影模糊程度
              spreadRadius: 1 //阴影扩散程度
              )
        ]

//            // 设置单圆角：左上角的圆角为5，右上角的圆角为10
//            borderRadius: BorderRadius.only(
//                    topLeft: Radius.circular(5),
//                   topRight: Radius.circular(10),
//              ),

        ),
  );
}

/**
 * 标题
 */
String getDataTitle(bean) {
  var variableJson = bean['variableJson'];
//  LogUtil.v("variableJson:$variableJson");
  variableJson = json.decode(variableJson);
  var ppProjectName = variableJson["title"]; //ppProjectName
  LogUtil.v("ppProjectName:$ppProjectName");
  if (ppProjectName == null) {
    ppProjectName = "";
  }
  return ppProjectName;
}

/**
 * 状态
 */
String getDataStatusText(bean) {
  var variableJson = bean['variableJson'];
//  LogUtil.v("variableJson:$variableJson");
  variableJson = json.decode(variableJson);
  var statusText = variableJson["statusText"]; //statusText
//  LogUtil.v("statusText:$statusText");
  if (statusText == null) {
    statusText = "";
  }
  return statusText;
}
